using System.Collections.Generic;
using System.Reflection;

namespace Plugins.Xml.Serialization.Internal
{
    using System;

    internal static class RuntimePropertyHelper
    {
        public static PropertyInfo GetInterfacePropertyInternal(Type interfaceType, string propertyName)
        {
            PropertyInfo property = null;
            foreach (Type type in interfaceType.GetInterfaces())
            {
                property = type.GetProperty(propertyName);
                if (property != null)
                {
                    return property;
                }
            }
            property = interfaceType.GetProperty(propertyName);
            if (property != null)
            {
                return property;
            }
            return null;
        }
        public static IEnumerable<PropertyInfo> GetInterfacePropertiesInternal(Type interfaceType)
        {
            foreach (Type type in interfaceType.GetInterfaces())
            {
                foreach (PropertyInfo property in type.GetProperties())
                {
                    yield return property;
                }
            }
        }
    }
}
